package com.capinfo.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.capinfo.base.BaseController;
import com.capinfo.base.CurrentUser;
import com.capinfo.core.annotation.Log;
import com.capinfo.entity.SysFileInfo;
import com.capinfo.entity.SysOffice;
import com.capinfo.service.SysFileInfoService;
import com.capinfo.service.SysOfficeService;
import com.capinfo.util.CommonUtil;
import com.capinfo.util.JsonUtil;
import com.capinfo.util.ReType;
import com.capinfo.utils.SysFileInfoBean;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @author: sunbenjin
 * @date: 2020/2/29
 **/
@Controller
@RequestMapping(value="/sysFile")
public class SysFileController extends BaseController {

    @Autowired
    private SysFileInfoService sysFileInfoService;

    @ApiOperation(value="batchUpdateFile",httpMethod = "POST",notes="批量更新预审材料结果")
    @PostMapping("batchUpdateFile")
    @ResponseBody
    public JsonUtil batchUpdateFile(@RequestBody List<SysFileInfo> fileInfoList){
        JsonUtil j = new JsonUtil();
        String userId = CommonUtil.getUser().getId();
        try {
            if(CollectionUtils.isNotEmpty(fileInfoList)){
                fileInfoList.forEach((data)->data.setUpdateBy(userId));
                sysFileInfoService.batchUpdate(fileInfoList);
            }
            j.setFlag(true);
            j.setMsg("保存成功");
        } catch (Exception e) {
            j.setMsg("保存失败");
            j.setFlag(false);

            e.printStackTrace();
        }
        return j;
    }



}
